<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #txt{
            color: #214283;
        }
    </style>
</head>
<body>
<ul id="city">

</ul>
<script type="text/javascript">
    var citylist = ["北京", "上海", "深圳"];
    for (var idx in citylist) {
        var text = citylist[idx];

        //创建空的li便签
        var tag = document.createElement("li");
        tag.innerText = text;

        //添加到id=city标签里面。DOM功能
        var parentTag = document.getElementById("city");
        parentTag.appendChild(tag);

    }
</script>
</body>
</html>